﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using CSharpDesign.DAL;
using CSharpDesign.BLL;

namespace CSharpDesign.Admin
{
    public partial class OrderStatistics : System.Web.UI.Page
    {
        SqlHelper data = new SqlHelper();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txttime.Value = DateTime.Now.ToShortDateString();
                Text1.Value = DateTime.Now.AddDays(1).ToShortDateString();
            }
        }
        protected void gvInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {


        }
        private void Get_Info()
        {
            try
            {
                gvInfo.DataSource = GetCodeBy(0);
                gvInfo.DataBind();
            }
            catch
            {

            }

        }
        protected void gvInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvInfo.PageIndex = e.NewPageIndex;
            Get_Info();
        }

        /// <summary>
        /// 鼠标移动变色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvInfo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            OrderStatisticsService.Color(e);
        }
        /// <summary>
        /// 查询订单
        /// </summary>
        /// <param name="iCount"></param>
        /// <returns></returns>
        public DataSet GetCodeBy(int iCount)
        {

            string SPName = this.SPName.Text;
            string txttime = this.txttime.Value;
            string Text1 = this.Text1.Value;

            try
            {
                string sql = OrderStatisticsService.Select_Strtop(iCount, SPName, txttime, Text1);
                return OrderStatisticsService.Sql_con(sql);
            }
            catch (Exception)
            {
                throw new Exception("查找失败");
            }
        }
        /// <summary>
        /// 查询总数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            string SPName = this.SPName.Text;
            string txttime = this.txttime.Value;
            string Text1 = this.Text1.Value;

            Get_Info();
            try
            {
                string sql = OrderStatisticsService.Select_Sum(SPName, txttime, Text1);
                string text = OrderStatisticsService.Result_Tip(sql);
                Label1.Text = text;
            }
            catch (Exception)
            {
                throw new Exception("查找失败");
            }

        }

    }
}